$(function(){
	//企业用户列表查询 
	selectCompanyList();
});

//企业用户列表查询 
function selectCompanyList(){
	$.ajax({
		type : "POST",
		url : "/userAdmin/companyList/search/",
		async : false,
		success:function(data){
			var companyList = data.companyList;
			var $tbody = $("#companyList tbody");
			if(companyList.length > 0) {
				for(var i=0;i<companyList.length;i++){
					var companyInfo = companyList[i];
					var loginNum = setLoginNum(companyInfo);
					var $tr = '<tr class="odd">';
					$tr += '<td>'+checkNull(loginNum)+'</td>';
					$tr += '<td>'+checkNull(companyInfo.phone)+'</td>';
					$tr += '<td>'+parseFloat(companyInfo.accountMoney).toFixed(2)+'元</td>';
					$tr += '<td>'+checkNull(companyInfo.belongCompanyName)+'</td>';
					$tr += '<td>'+checkNull(companyInfo.companyDomainName)+'</td>';
					$tr += '<td>'+'</td>';
					$tr += '<td>'+checkNull(companyInfo.provinceCodeName) + checkNull(companyInfo.cityCodeName) + checkNull(companyInfo.areaCodeName) + checkNull(companyInfo.address)+'</td>';
					$tr += '<td><button type="button" class="btn btn-primary" onclick="toDetail('+companyInfo.userId+');">查看详情</button>';
					$tr += '<button type="button" class="btn btn-danger" onclick="staffList('+companyInfo.userId+');">员工清单</button>';
					$tr += '</td></tr>';
					$tbody.append($tr);
				}
			}else {
				var $tr = '<tr class="odd"><td colspan="7">暂无数据！</td></tr>';
				$tbody.append($tr);
				alert("查询失败！")
			}
		}
	})
}

//查看详情
function toDetail(userId){
	location.href="/userAdmin/companyDetail/"+userId;
}
//员工清单
function staffList(userId){
	//location.href="/userAdmin/companyDetail/"+userId;
}

//检测非空
function checkNull(para){
	if(para == null){
		return "";
	}else{
		return para;
	}
}

//设置登陆账号
function setLoginNum(companyInfo){
	if(companyInfo.userEmail != "" && companyInfo.userEmail != null){
		return companyInfo.userEmail;
	}else if(companyInfo.userTel != "" && companyInfo.userTel != null){
		return companyInfo.userTel;
	}else{
		return "";
	}
}







